/**
 * 
 */
package com.xy.commons;

/**
 * @author admin
 * 
 */
public class SqlUtil {
	public static String buildPageSql(String sql, int start, int end) {
		StringBuffer sb = new StringBuffer();
		sb.append("SELECT PAGE2.*  FROM (SELECT PAGE1.*, ROWNUM RM FROM (");
		sb.append(sql);
		sb.append(") PAGE1 WHERE ROWNUM <= ").append(end).append(") PAGE2 WHERE PAGE2.RM > ").append(start);
		return sb.toString();
	}

	public static String buildCountSql(String sql) {
		StringBuffer sb = new StringBuffer();
		sb.append("SELECT COUNT(1) FROM (").append(sql).append(")");
		return sb.toString();
	}
	
}
